package com.spic.business.getui.config;

import com.getui.push.v2.sdk.ApiHelper;
import com.getui.push.v2.sdk.GtApiConfiguration;
import com.getui.push.v2.sdk.api.PushApi;
import com.getui.push.v2.sdk.api.UserApi;
import com.spic.business.getui.constant.PushConstant;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @Author: wzl
 * @Date: 2022-03-21 15:31
 */
@Component
public class PInit {

    @Bean("platformPushApi")
    public PushApi getPushApi(){
        GtApiConfiguration apiConfiguration = new GtApiConfiguration();
        //填写应用配置
        apiConfiguration.setAppId(PushConstant.APP_ID);
        apiConfiguration.setAppKey(PushConstant.APP_KEY);
        apiConfiguration.setMasterSecret(PushConstant.MASTER_SECRET);
        // 接口调用前缀，请查看文档: 接口调用规范 -> 接口前缀, 可不填写appId
        apiConfiguration.setDomain("https://restapi.getui.com/v2/");
        // 实例化ApiHelper对象，用于创建接口对象
        ApiHelper apiHelper = ApiHelper.build(apiConfiguration);
        // 创建对象，建议复用。目前有PushApi、StatisticApi、UserApi
        PushApi pushApi = apiHelper.creatApi(PushApi.class);
        return  pushApi;
    }

    @Bean("platformUserApi")
    public UserApi getUserApi() {
        GtApiConfiguration apiConfiguration = new GtApiConfiguration();
        //填写应用配置
        apiConfiguration.setAppId(PushConstant.APP_ID);
        apiConfiguration.setAppKey(PushConstant.APP_KEY);
        apiConfiguration.setMasterSecret(PushConstant.MASTER_SECRET);
        // 接口调用前缀，请查看文档: 接口调用规范 -> 接口前缀, 可不填写appId
        apiConfiguration.setDomain("https://restapi.getui.com/v2/");
        // 实例化ApiHelper对象，用于创建接口对象
        ApiHelper apiHelper = ApiHelper.build(apiConfiguration);
        // 创建对象，建议复用。目前有PushApi、StatisticApi、UserApi
        UserApi userApi = apiHelper.creatApi(UserApi.class);
        return  userApi;
    }


    public String pageName(){
        return PushConstant.PACKAGE_NAME;
    }
}
